window.workspace = function(){
	var response  = <?#$respons?>;
	var store, grid, sm;
	var sid = {'query':Ext.id(), 'status':Ext.id(), 'origin':Ext.id(), 'sdate':Ext.id(), 'edate':Ext.id()};
	store = new Ext.data.JsonStore({
	    autoDestroy	: true,
	    url			: '/admin/live/basic/account/dolist.html',
	    remoteSort	: true,
	    sortInfo	: {
	            field		: 'userid',
	            direction	: 'DESC'
		},
		baseParams	: {
			start	: 0,
			limit	: main.pageSize
		},
		autoLoad		: true,
	    root			: 'dataset',
	 	totalProperty	: 'total',
	    fields			: ['userid', 'uin', 'nickname', 'regtime', 'thumb', 'sex', 'birth', 'regorigin',
	        'sign', 'lv', 'exp', 'vipid', 'motorid', 'issuper', 'lastip', 'totalcoin', 'conscoin', 'regip',
	        'email', 'mobile', 'city', 'status', 'address', 'isrobot', 'lasttime', 'money', 'lastcoin']
	});
	sm   = new Ext.grid.CheckboxSelectionModel();
 	grid = {
		xtype		: 'grid',
		title		: response.title,
	    store		: store,
		region		: 'center', 
	    columns		: [
	        sm,
			{header: '会员ID', width:60, sortable:true, dataIndex:'userid'},
			{header: 'PS-UIN', width:60, sortable:true, dataIndex:'uin'},
			{header: '昵称', width:80, dataIndex:'nickname'},
			{header: '性别',    width:50, sortable:true, dataIndex:'sex', renderer:function(v){
				return response.sex[v];
			}},
			{header: '出生日期', width:80, dataIndex:'birth'},
			{header: '等级/经验', width:60, dataIndex:'lv', renderer:function(v, mata, obj){
				return v+'/'+obj.get("exp");
			}},
			{header: '登录邮箱', width:80, dataIndex:'email'},
			{header: '[代币]总/消费/余额', width:100, dataIndex:'lastcoin', renderer:function(v, mata, obj){
				return obj.get("totalcoin") + '/' + obj.get("conscoin") + '/' + v;
			}},
			{header: '充值总额', width:60, sortable:true, dataIndex:'money'},
			{header: '状态', width:60, dataIndex:'status', renderer:function(v){
				return response.status[v];
			}},
			{header: '来源', width:60, dataIndex:'regorigin', renderer:function(v){
				return response.origin[v];
			}},
			{header: '是否客服', width:60, dataIndex:'issuper', renderer:function(v){
				return response.yes2no[v];
			}},
			{header: '是否机器人', width:60, dataIndex:'isrobot', renderer:function(v){
				return response.yes2no[v];
			}},
			{header: '注册时间', width:100, dataIndex:'regtime'},
			{header: '注册IP', width:80, dataIndex:'regip'},
			{header: '最后登录IP', width:80, dataIndex:'lastip'},
			{header: '最后登录时间', width:100, dataIndex:'lasttime'}
		],
	    viewConfig	: {
	        forceFit	 : true,
	        scrollOffset : 0
	    },
	    listeners	: {'render':function(obj){
			main.gridRender(obj, ['sign', 'city', 'thumb']);
    	}},
	    sm			: sm,
	    stripeRows	: true,
	    tbar		: [{
			text	: '刷新',
			iconCls	: 'icon-refresh',
			handler : function(){
				store.reload(); 
			}
	    },'-',{
			text	: '禁用/解禁',
			iconCls	: 'icon-edit',
			url     : '/admin/live/basic/account/dostatus.html',
			handler : function() {
				var rcs = sm.getSelections();
				if(Ext.isEmpty(rcs)) {
					Ext.Msg.alert(GLang['30003'], GLang['30020']);
					return;
				}
				var ids= [];
				Ext.each(rcs, function(item){
					ids.push(item.get('userid'));
				});
				Ext.Msg.prompt(GLang['30021'], GLang['30022'], function(btn, memo){
					if(btn=="ok") {
						Ext.Ajax.request({
							url		: '/admin/live/basic/account/dostatus.html',
							params	: {'ids':ids.join(','), 'remark':memo},
							success : function(resp, req){
								var data = Ext.decode(resp.responseText);
								if(data.code == 0) {
									store.reload(); 
								} else {
									Ext.Msg.alert(GLang['30003'], data.msg);
								}
							}
						});
					}
				}, null, true);
			}
		},'-',{
			text	: '[客服号]设置/取消',
			url     : '/admin/live/basic/account/dosuper.html',
			iconCls	: 'icon-user-edit',
			handler : function() {
				var rcs = sm.getSelections();
				if(Ext.isEmpty(rcs)) {
					Ext.Msg.alert(GLang['30003'], GLang['30020']);
					return;
				}
				var ids= [];
				Ext.each(rcs, function(item){
					ids.push(item.get('userid'));
				});
				Ext.Msg.confirm(GLang['30003'], GLang['30023'], function(btn){
					if(btn=="yes") {
						Ext.Ajax.request({
							url		: '/admin/live/basic/account/dosuper.html',
							params	: {'s':ids.join(','), 'isrobots':0},
							success : function(resp, req){
								var data = Ext.decode(resp.responseText);
								if(data.code == 0) {
									store.reload(); 
								} else {
									Ext.Msg.alert('Tips', data.msg);
								}
							}
						});
					}
				});
			}
		},'-',{
			text	: '[机器人]设置/取消',
			iconCls	: 'icon-user-group-delete',
			url     : '/admin/live/basic/account/dosuper.html',
			handler : function() {
				var rcs = sm.getSelections();
				if(Ext.isEmpty(rcs)) {
					Ext.Msg.alert(GLang['30003'], GLang['30020']);
					return;
				}
				var ids= [];
				Ext.each(rcs, function(item){
					ids.push(item.get('userid'));
				});
				Ext.Msg.confirm(GLang['30003'], GLang['30023'], function(btn){
					if(btn=="yes") {
						Ext.Ajax.request({
							url		: '/admin/live/basic/account/dosuper.html',
							params	: {'s':ids.join(','), 'isrobots':1},
							success : function(resp, req){
								var data = Ext.decode(resp.responseText);
								if(data.code == 0) {
									store.reload(); 
								} else {
									Ext.Msg.alert(GLang['30003'], data.msg);
								}
							}
						});
					}
				});
			}
		},'-','<b>检索关键词：</b>','邮箱/昵称:',{
			xtype       : 'textfield',
			id	    	: sid.query,
			width	    : 80
		},'状态:',{
			xtype		: 'combo',
			store		: new Ext.data.ArrayStore({
		        fields: ['id','name'],
		        data: main.cv2Array(response.status)
		    }),
			displayField	: 'name',
			valueField		: 'id',
			mode			: 'local',
			autoSelect 		: true, 
			triggerAction	: 'all',
			width			: 60,
			id  			: sid.status
		},'来源:',{
			xtype		: 'combo',
			store		: new Ext.data.ArrayStore({
		        fields: ['id','name'],
		        data: main.cv2Array(response.origin)
		    }),
			displayField	: 'name',
			valueField		: 'id',
			mode			: 'local',
			autoSelect 		: true, 
			triggerAction	: 'all',
			width			: 60,
			id  			: sid.origin
		},'注册时间:',{
			xtype       : 'datefield',
			id  		: sid.sdate,
			format		: 'Y-m-d',
			width	    : 100
		},'<->',{
			xtype       : 'datefield',
			id  		: sid.edate,
			format		: 'Y-m-d',
			width	    : 100
		},'-',{
			text			: '检索',
			iconCls			: 'icon-search',
			handler: function() {
				store.baseParams.query  = Ext.getCmp(sid.query).getValue();
				store.baseParams.status = Ext.getCmp(sid.status).getValue();
				store.baseParams.origin = Ext.getCmp(sid.origin).getValue();
				store.baseParams.sdate  = Ext.getCmp(sid.sdate).getValue();
				store.baseParams.edate  = Ext.getCmp(sid.edate).getValue();
				store.reload(); 
			}
		}],
		bbar		: new Ext.PagingToolbar({
			pageSize	: main.pageSize,
			store		: store,
			displayInfo	: true
		})
	};
	return grid;
}();